home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / pyshared / rdflib / Variable.py < prev   
Encoding:
Python Source  |  2009-03-04  |  587 b   |  28 lines

  1. from rdflib.Identifier import Identifier
  2. try:
  3.     from hashlib import md5
  4. except ImportError:
  5.     from md5 import md5    
  6.  
  7. class Variable(Identifier):
  8.     """
  9.     """
  10.     __slots__ = ()
  11.     def __new__(cls, value):
  12.         if value[0]=='?':
  13.             value=value[1:]
  14.         return unicode.__new__(cls, value)
  15.  
  16.     def __repr__(self):
  17.         return self.n3()
  18.  
  19.     def n3(self):
  20.         return "?%s" % self
  21.  
  22.     def __reduce__(self):
  23.         return (Variable, (unicode(self),))
  24.  
  25.     def md5_term_hash(self):
  26.         d = md5(str(self))
  27.         d.update("V")
  28.         return d.hexdigest()